/*
 * Copyright (c) 2013.
 * 游戏服务器核心代码编写人陈磊拥有使用权
 * 联系方式：E-mail:13638363871@163.com ;qq:502959937
 * 个人博客主页：http://my.oschina.net/chenleijava
 */

package com.dc.gameserver.serverCore.service.battle.coreBattleLogic.singleCardType;

import com.dc.gameserver.hardCode.CardType;
import com.dc.gameserver.serverCore.service.battle.GameFormula;
import com.dc.gameserver.serverCore.service.battle.coreBattleLogic.AbstractSingleLogic;
import com.dc.gameserver.serverCore.service.battle.coreBattleLogic.ISoul;
import com.dc.gameserver.serverCore.service.cardModule.CardBox;
import com.dc.gameserver.serverCore.service.cardModule.CardBoxManager;
import com.dc.gameserver.serverCore.service.character.GameCharacter;
import org.springframework.stereotype.Service;

/**
 * @author 石头哥哥 </br>
 *         Project : gameServer1.1</br>
 *         Date: 13-11-2  11</br>
 *         Time: 下午11:02</br>
 *         Connect: 13638363871@163.com</br>
 *         packageName: Server.ServerCore.Service.fightProcess.singleCardType</br>
 *         注解：处理单个神识牌
 */
@Service
public class singleSoulLogic extends AbstractSingleLogic {

    @Override
    public void PostConstruct() {
        SINGLES[CardType.SOUL_TYPE.getType()]=this;
    }

    /**
     * 处理不同类型牌的逻辑
     * @param p1   出牌对象,p1使用任何牌有效
     * @param p2   没有出牌的玩家
     */
    @Override
    public void SingleLogicHandle(GameCharacter p1,GameCharacter p2) {
        notifyPlayerGetCardSingle(p1);  //p1玩家出神识牌
    }

    /**
     * 通知玩家抽取神识判定牌
     * @param gameCharacter 出神识牌对象
     */
    private  void notifyPlayerGetCardSingle(GameCharacter gameCharacter){
        CardBox cardBox= CardBoxManager.getCardBoxByID(gameCharacter.getCardBoxID());
        GameCharacter otherPlayer=cardBox.getOtherPlayer(gameCharacter);
        //gameCharacter 出神识牌  ,是否造成对手眩晕
        int soulType=GameFormula.getSoulSkillType(gameCharacter.getOutCardsList().size());
        boolean status= ISoul.SOULS[soulType].SoulHandle(gameCharacter, otherPlayer);
        if (status&&otherPlayer.getCurrentShield()==0||status&&otherPlayer.getDizzinessTimes()!=0){
            return;
        }
        cardBox.flushBloodAndMagic();
        cardBox.resetRoundResource();

    }
}
